//
//  WPWithdrawalVC.m
//  wobingwoyi
//
//  Created by WGP on 16/8/4.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPWithdrawalVC.h"
#import "WPWithDrawsureVC.h"

@interface WPWithdrawalVC ()

@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *cardNumField;
@property (weak, nonatomic) IBOutlet UITextField *cardType;

@end

@implementation WPWithdrawalVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

- (IBAction)cancelBtnDidClick:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)nextStepBtnDidClick:(UIButton *)sender
{
    if (!(self.nameField.text.length && self.cardNumField.text.length))
    {
        [self showErrorInfoWithStatus:@"卡号或名字不能为空"];
        return ;
    }
    
    if(![NSString checkCardNo:self.cardNumField.text])
    {
        [self showErrorInfoWithStatus:@"卡号不正确"];
        return ;
    }
    
    if(!self.cardType.text.length)
    {
        [self showErrorInfoWithStatus:@"请输入银行类型"];
        return ;
    }
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"WPWithDrawsureVC" bundle:nil];
    WPWithDrawsureVC *vc = [sb instantiateInitialViewController];
    
    NSString *lastNum = [self.cardNumField.text substringFromIndex:self.cardNumField.text.length-4];
    vc.infoStr = [NSString stringWithFormat:@"%@ (%@)",self.cardType.text,lastNum];
    vc.coinCountStr = self.coinCountStr;
    vc.dict = @{@"name":self.nameField.text,@"payAccount":self.cardNumField.text,@"bank":self.cardType.text,@"gold":@([self.coinCountStr intValue])};
    
    [self.navigationController pushViewController:vc animated:YES];
}


@end
